package com.example.mapper;

import com.example.pojo.User;
import com.example.pojo.admin.SearchBean;
import org.apache.ibatis.annotations.*;

import java.util.List;
import java.util.Map;

/**
 * @Description TODO
 * @Author fantasy
 * @Date 2024/6/26 22:09
 **/


@Mapper
public interface UserMapper {

    @Select("select * from big_user")
    List<User> getUserList();
    @Select("select * from big_user where username = #{username}")
    User findByUsername(String username);
    @Insert("insert into big_user(username,password,create_time,update_time) values(#{username},#{password},now(),now())")
    void registerUser(User user);

    @Update("update big_user set nickname = #{nickname},email = #{email},update_time = now() where id = #{id}")
    void update(User user);

    /**
     * @param avatarUrl
     * @param id
     * @return void
     * @description 更新头像，如果是多个入参，单独更新pojo的某个属性，则需要对所有参数都使用@Param注解
     */
    @Update("update big_user set user_pic = #{avatarUrl},update_time = now() where id = #{id}")
    void updateAvatar(@Param("avatarUrl") String avatarUrl, @Param("id") Integer id);

    List getArticleInfo(Integer id);

    List getDayInfo(Map map);

    @Select("select * from big_user where id = #{id}")
    User getUserById(Integer id);

    List<User> getUserLikeList(SearchBean searchBean);

    @Insert("insert into big_user(username,password,nickname,email,user_pic,create_time,update_time) " +
            "values(#{username},#{password},#{nickname},#{email},#{userPic},now(),now())")
    void addUser(User user);

    @Update("update big_user set password = #{passwd},update_time = now() where id = #{id}")
    void updatePasswd(@Param("passwd") String passwd, @Param("id") Integer id);

    @Update("update big_user set active = 0 where id = #{id}")
    void delete(Integer id);

    @Update("update big_user set active = 1 where id = #{id}")
    void revoke(Integer id);

    List<User> getUserFriend(Map map);
}
